
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>
        <link rel="stylesheet" href="${path}/css/admin2.css">
        <link rel="stylesheet" href="${path}/css/coursemanage-kb.css">
        <style>
            table{
                border: 0;
            }
            table th, table td{
                border: 0;
                text-align: left;
            }
            
            label{
                display: inline-block;
                width: 130px;
                font-weight: 700;
            }
            td:nth-child(odd) label{
                margin-left: 25%;
            }
            input{
                width:188px;
                height:30px;
            }
            select{
                width:194px;
                height:38px;
            }
            #passport-modal,#majorHis-modal{
                margin: 12% auto;
                padding: 10px;
                width: 600px;
                position: relative;
    			z-index: 2000;
    			background: #fff;
            } 
            #passTab td,#passTab th{
            	border: 1px solid #DDDDDD;
                text-align:center;
            }
            
             #addPassport-modal{
                position: absolute;
				z-index: 4000;
				top: 0px;
				width: 100%;
            } 
           .addPassport-modal{
            margin: 300px auto;
			padding: 10px 10px 10px 50px;
			width: 300px;
			background: none repeat scroll 0% 0% #FFF;
            } 
            .if-modal{
            margin: 300px auto;
			background: none repeat scroll 0% 0% #FFF;
                padding: 10px;
                width: 200px;
               
            } 
            #if-modal{
            	 position: absolute;
				z-index: 4000;
				top: 0px;
				width: 100%;
           
            }
        </style>
        <script>
            var _current_item = "#adminstumanage";
        </script>
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
    </head>
    <body>
        <!--header-->
           <div id="above-mask">
            <div class="pannel hide" id="passport-modal">
                <div class="am-modal-dialog">
                    <div class="close-container">
                        <a class="close" onclick="hide('#mask, #above-mask, #passport-modal')">&times;</a>
                    </div>
                   <div> <button type="button" style="width:45px;height:25px;" onclick="show('#addPassport-modal');">新增</button>
                   <span style="font-size:20px;padding-left:5px;">初始护照号：</span><span style="font-size:21px;" id="initPassport"></span>
                   </div>
                    <form action="" method="post">
                        <table class="table table-bordered" id="passTab">
                          <thead>
                                <tr>
                                    
                                    <th style="width:40%;">护照号</th>
                                    <th style="width:40%;">更新时间</th>
                                    <th style="width:20%;">操作</th>
                                </tr>
                            </thead>
                            <tbody id="tbody">
                            </tbody>
                        </table>
                        
                    </form>		
                </div>
            </div>
            <div class="hide" id="addPassport-modal" >
                <div class="addPassport-modal pannel ">
                    <div class="close-container">
                        <a class="close" onclick="hide('#addPassport-modal')">&times;</a>
                    </div>
                   <form>
                        <table class="table table-bordered">
                            <tr>
                                <td>护照号</td>
                                <td><input type="text" placeholder="必填" id="addPassport" required="required"></td>
                            </tr>
                            <tr>
                                <td>更新时间</td>
                                <td><input type="text" placeholder="必填"  id="addPassportTime"class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" required="required"></td>
                            </tr>
                            <tr><td colspan="2"><button style="width:260px;" type="button" id="add_btn">确定</button></td></tr>
                        </table>
                   </form>
                </div>
            </div>
            
            <div class="pannel hide" id="majorHis-modal">
                <div class="am-modal-dialog">
                    <div class="close-container">
                        <a class="close" onclick="hide('#mask, #above-mask, #majorHis-modal')">&times;</a>
                    </div>
                        <table class="table table-bordered" id="passTab">
                          <thead>
                                <tr>
                                    
                                    <th style="width:40%;">专业</th>
                                    <th style="width:40%;">更新时间</th>
                                </tr>
                            </thead>
                            <tbody id="majorHisTab">
                            </tbody>
                        </table>	
                </div>
            </div>
            
            <div class="hide "  id="if-modal">
                  <div class="pannel if-modal" >
                <div class="close-container">
                    <a class="close" onclick="hide('#if-modal')">&times;</a>
                </div>
                    <div style="border:1px solid #DDDDDD;padding-left:40px">
                            <br />是否删除该护照号？<br /><br />
                            <button style="width:30px;margin-left:10px" onclick="del();" id="del">是</button>
                    		<button style="width:30px;margin-left:30px" onclick="hide('#if-modal')" class="cancel">否</button></td>
                   </div>
         </div>
            </div>
            
        </div>
        <div id="mask"></div>
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>
            <div id="container">
                <div id="inner-border">
                    <#if studentInfo?exists> 
                    <#if studentInfo.studentStatus==0>
                    <form action="${path}/adminstumanage/update" method="post" >
                        <input type="hidden" name="studentInfo.id" value="${studentInfo.id}">
                        <input type="hidden" name="studentInfo.passportNo" value="${studentInfo.passportNo}">
                        <table>
                            <tr>
                                <td>
                                    <label>初始护照号：</label>
                                    ${studentInfo.passportNo}
                                    <script>$("#initPassport").text('${studentInfo.passportNo}');</script>                                
                                    </td>
                                <td>
                                    <label><a style="text-decoration:underline;color:#006699" passportNo="${studentInfo.passportNo}" onclick="newPassPortNo(this);">最新护照号</a>：</label>
                                    <input type="text" name="studentInfo.newPassportNo" id="newPno" disabled value=" ${studentInfo.newpassportNo}" >
                                    
                                </td>
                            </tr>
							<tr>
                                <td>
                                    <label>学号：</label>
                                    <input type="text" name="studentInfo.sNo" value="${studentInfo.sNo!}" >
                                </td>
                                <td>
                                    <label>中文名：</label>
                                    <input type="text" name="studentInfo.chineseName" value="${studentInfo.chineseName!}">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>姓：</label>
                                    <input type="text" placeholder="必填" name="studentInfo.lastName" value="${studentInfo.lastName}" required="required">
                                </td>
                                <td>
                                    <label>名：</label>
                                    <input type="text" placeholder="必填" name="studentInfo.firstName" value="${studentInfo.firstName}" required="required">
                                </td>
                            </tr>

                            <tr>
                                <td>
                                    <label>国籍：</label>
                                    <input type="text" placeholder="必填" name="studentInfo.nationality"  value="${studentInfo.nationality}" required="required">
                                </td>
                                <td>
                                    <label>性别：</label>
                                    <select name="studentInfo.sex">
                                        <#if studentInfo.sex=="female"||studentInfo.sex=="女">
                                        <option value="male" >男</option>
                                        <option value="female" selected="selected">女</option>
                                        <#else>
                                        <option value="male" selected="selected">男</option>
                                        <option value="female" >女</option>
                                        </#if>
                                    </select>
                                </td>
                            </tr>
                            
                            <tr>
                                <td>
                                    <label>状态：</label>
                                    <select name="studentInfo.studentStatus">
                                    <option value="0">正常</option>
                                    <option value="1">休学</option>
                                    <option value="2">转专业</option>
                                    <option value="3">退休</option>
                                    </select>
                                    </td>
                                <td>
                                    <label>班级：</label>
                                    <!--<input type="text" placeholder="必填" name="studentInfo.class" value="${studentInfo.stuClass}" required="required"> -->
                                    <select name="studentInfo.class" id="clazz" required="required" data-index="${studentInfo.stuClass}">
                                        <#if allclass?exists>
                                        <#list allclass as clz>
                                        <option value="${clz}">${clz}</option>                                                     
                                        </#list>
                                        </#if>
                                    </select>
                                </td>
                            </tr>
<script type="text/javascript">
    $().ready(function(){
        var myclazz = $("#clazz").attr("data-index");
        $("#clazz option").each(function(index){
            var clazzName = $(this).text();
            clazzName = clazzName.substring(clazzName.indexOf(':')+1,clazzName.indexOf('}'));
            if(myclazz == clazzName)
                $(this).attr("selected","selected");
            $(this).text(clazzName);
            $(this).attr("value",clazzName);
        });
    });
</script>
                            <tr>
                                <td>
                                    <label><a style="text-decoration:underline;color:#006699"  sNo="${studentInfo.sNo!}" onclick="majorHis(this)">专业</a>：</label>
                                    <!--  <input type="text" placeholder="必填"name="studentInfo.majorName" value="${studentInfo.majorName}" required="required">
                                    --> 
                                    <select name="studentInfo.majorName" id="majorName" required="required">
                                        <#if majorName?exists>
                                        <#list majorName as mn>
                                        <#if mn.majorName==studentInfo.majorName>
                                        <option value="${mn.majorName}" selected="selected">${mn.majorName}</option>
                                        <#else>
                                        <option value="${mn.majorName}">${mn.majorName}</option>
                                        </#if>
                                        </#list>
                                        </#if>
                                    </select>
                                </td>
                                <td>
                                    <label>签证到期日：</label>
                                    <input type="text" placeholder="必填" name="studentInfo.visaEndDate"  value="${studentInfo.visaEndDate}" class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" required="required"></td>
                            </tr>

                            <tr>
                                <td>
                                    <label>入学年份：</label>
                                    ${studentInfo.eduStartDate}
                                </td>
                                <td>
                                    <label>入学季度：</label>
                                    ${studentInfo.eduSeason}
                                </td>
                            </tr>



                            <tr>
                               
                                <td>
                                    <label >出生日期：</label>
                                    <input type="text" name="studentInfo.birthday" class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" value="${studentInfo.birthday!}">
                                </td>
                                <td>
                                    <label>宿舍号：</label>
                                    <input type="text" name="studentInfo.dormitoryNo" value="${studentInfo.dormitoryNo!}">
                                </td>

                            </tr>

                            <tr>
                                <td>
                                    <label>联系电话：</label>
                                    <input type="text"  name="studentInfo.phone"  value="${studentInfo.phone!}" >
                                </td>
                                <td>
                                    <label>邮箱地址：</label>
                                    <input type="text"  name="studentInfo.mailbox"  value="${studentInfo.mailbox!}" >
                                </td>
                            </tr>
                            <tr>
                                
                                <td> <br />
                                <label><button type="submit" >提交</button></label>
                                    
                                </td>
                                 
                            </tr>
                        </table>
                    </form>
                    <#else>
                    <table class="table table-striped">
                        <tr>
                           <td>
                                <label>初始护照号：</label>
                                ${studentInfo.passportNo}
                            </td>
                            <td>
                                <label>最新护照号：</label>
                                ${studentInfo.newpassportNo}
                            </td>
                        </tr>
                        
                         <tr>
                            <td>
                                <label>学号：</label>
                                ${studentInfo.sNo!}
                            </td>
                             <td>
                                <label>中文名：</label>
                                ${studentInfo.chineseName!}
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <label>姓：</label>
                                ${studentInfo.lastName}
                            </td>
                            <td>
                                <label>名：</label>
                                ${studentInfo.firstName} 
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <label>国籍：</label>
                                ${studentInfo.nationality}
                            </td>
                            <td>
                                <label>性别：</label>
                                ${studentInfo.sex}
                            </td>
                        </tr>
                        
                        
                        <tr>
                            <td>
                                <label>状态：</label>
                                
                            </td>
                            <td>
                                <label>班级：</label>

                            </td>
                        </tr>

                        <tr>
                            <td>
                                <label>专业：</label>
                                ${studentInfo.majorName}
                            </td>
                            <td>
                                <label>签证到期日：</label>
                                ${studentInfo.visaEndDate}
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <label>入学年份：</label>
                                ${studentInfo.eduStartDate}
                            </td>
                            <td>
                                <label>入学季度：</label>
                                ${studentInfo.eduSeason}
                            </td>
                        </tr>

                        <tr>
                           
                            <td>
                                <label >出生日期：</label>
                                ${studentInfo.birthday!}
                            </td>
                              <td>
                                <label>宿舍号：</label>
                                ${studentInfo.dormitoryNo!}
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <label>联系电话：</label>
                                ${studentInfo.phone!}
                            </td>
                            <td>
                                <label>邮箱地址：</label>
                                ${studentInfo.mailbox!}
                            </td>
                        </tr>

                        <tr>
                          
                            <td><label>
                                <button class="cancel" onclick="window.history.go(-1)" >返回</button>
                            </label>
                            </td>
                        </tr>
                    </table>
                    </#if>
                    </#if>

                </div>
                <div id="footer"></div>
            </div>
        </div>
        <script type="text/javascript" src="${path}/js/admin-main-appearance.js"></script>
        <script type="text/javascript" src="${path}/js/My97DatePicker/WdatePicker.js"></script>
        <script>
        function newPassPortNo(node){
        	var passportNo = node.getAttribute("passportNo");
        	//alert(passportNo);
        	  $.ajax({
            async: false,
            type: "POST",
            url: "${path}/adminstumanage/ajaxlook",
            dataType: "json",
            data: {
                passportNo:passportNo,
            },
            success: function (data) {
            //alert(JSON.stringify(data));
                show('#mask, #above-mask, #passport-modal');
                $("#tbody").html("");
                $.each(data,function(num,data){
                 $("#passTab").append('<tr><td>'+data.newpassportNo+'</td><td>'+data.time+'</td><td></td></tr>');
                })
                 
            },
            error: function (err) {
                
            },
        }); 
        	
        	
        }
        $("#add_btn").on("click",function(){
        	hide('#addPassport-modal');
        	var passportNo=$("#initPassport").text();
        	//alert($("#initPassport").text());
        	var newPassport = $("#addPassport").val();
        	var time = $("#addPassportTime").val();
        	if(newPassport==""){
        		return false;
        	}else{
        		  $.ajax({
                     async: false,
                     type: "POST",
                     url: "${path}/adminstumanage/updatenewpassportNo",
                     dataType: "json",
                     data: {
                     passportNo:passportNo,
                     newpassportNo:newPassport,
                     time:time,
                     },
                     success: function (data) {
                         $("#passTab").append('<tr><td>'+newPassport+'</td><td>'+time+'</td>'+
                '<td><button class="delete" type="button" style="width:45px;height:25px;margin:0;" newPassport="'+newPassport+'"onclick="dell(this);">删除</button></td></tr>');
				$("#newPno").val(newPassport);
                     },
                     error: function (err) {
                         
                     },
                 }); 
        		
        	}
        	
        	})
        	
        	var trIndex
        	function dell(node){
        	trIndex = node.parentNode.parentNode.rowIndex;
        	//alert(trIndex)
        	newPassport=node.getAttribute("newPassport");
        	$("#del").attr("newPassport",newPassport);
        	show('#if-modal');
        }
        	function del(){
        		//alert(trIndex);
        		var newPassport = $("#del").attr("newPassport");
        		  $.ajax({
                     async: false,
                     type: "GET",
                     url: "${path}/adminstumanage/ajaxdeletenewpassportNo",
                     dataType: "json",
                     data: {
                         newpassportNo:newPassport,
                     },
                     success: function (error) {
                         alert("success");
                        hide('#if-modal');
        				$("#newPno").val("");
        				document.getElementById('passTab').deleteRow(trIndex);
                     },
                     error: function (err) {
                         alert("error");
                     },
                 }); 
        	
        	
        }
        
        function majorHis(obj){
        var sNo = obj.getAttribute("sNo");
        alert(sNo);
        $("#majorHisTab").html("");
                         
         $.ajax({
                     async: false,
                     type: "GET",
                     url: '${path}/adminstumanage/ajaxlookmajor',
                     dataType: "json",
                     data: {
                         sNo:sNo,
                     },
                     success: function (data) {
                     $.each(data,function(num,data){
                     $("#majorHisTab").append("<tr><td>"+data.newmajorName+"</td><td>"+data.time+"</td></tr>");
        			
                     })
                     	show('#mask, #above-mask,#majorHis-modal');
                     	//alert(JSON.stringify(data));
                     },
                     error: function (err) {
                         alert("error");
                     },
                 }); 
       
        }
        </script>
    </body>
</html>
